<?php

class ajoutExpositionValidation extends Controller {


	function index()
	{
		
		$this->load->database();
		$this->load->library('form_validation');
		$this->load->helper('form');
		$this->load->helper('url');
				
		$data;	
		
		$this->form_validation->set_rules('nom',  'Nom', 'required');	
		$this->form_validation->set_rules('dateDebut',  'Date de debut', 'required');
		$this->form_validation->set_rules('dateFin',  'Date de fin', 'required');
		$this->form_validation->set_rules('ville',  'Ville', 'required');
		$this->form_validation->set_rules('adresse',  'Adresse', 'required');
		$this->form_validation->set_rules('codePostal',  'Code postal', 'required');
		$this->form_validation->set_rules('pays',  'Pays', 'required');
		
		$this->form_validation->set_message('required', 'Vous n\'avez pas renseigner le champs %s ');
	
		
		if ($this->form_validation->run() ){ 
		
			$date = date("j M Y");
			$data["nom"]=($this->input->post('nom')) ;
			$this->db->set('nom',$this->input->post('nom'));		
			$this->db->set('presentation',$this->input->post('presentation'));
			$this->db->set('descriptif',$this->input->post('descriptif'));
			$this->db->set('date_debut',$this->input->post('dateDebut'));
			$this->db->set('date_fin',$this->input->post('dateFin'));
			$this->db->set('date_publication',$date);
			$this->db->set('adresse',$this->input->post('adresse'));
			$this->db->set('code_postal',$this->input->post('codePostal'));
			$this->db->set('ville',$this->input->post('ville'));
			$this->db->set('pays',$this->input->post('pays'));
			if (isset($_COOKIE['login'])) $this->db->set('utilisateur',$_COOKIE['login']);
			
			$this->db->insert('exposition'); 	
		
			$this->load->view('ajoutExpositionValidation',$data);
		}
		
		else $this->load->view('ajoutExposition');
		
		
		
	}
	
	
	

}
?>
